﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;

namespace MvcEngine.Core.Helpers
{
    public class FormsAuthenticationHelper: IFormsAuthenticationHelper
    {
        public FormsAuthenticationHelper()
        {

        }

        public static IFormsAuthenticationHelper Current 
        {
            get { return IoC.Resolve<IFormsAuthenticationHelper>(); }
        }

        public void SignIn(string userName, bool createPersistentCookie)
        {
            FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
        }

        public void SignOut()
        {
            FormsAuthentication.SignOut();
        }

        public string HashValue(string value, string hashFormat) 
        {
            return FormsAuthentication.HashPasswordForStoringInConfigFile(value.ToLowerInvariant().Trim(), hashFormat).ToLowerInvariant();
        }
    }
}
